<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100%;
        }
        
        div {
            width: 500px;
            border: 1px solid #000;
        }
    </style>
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>

</head>

<body>

    <button id="but">发送 get 请求</button>
    <section class="box"></section>
    <script>
        $(function() {
            $('#but').click(function() {
                // res - response
                $.get('http://www.liulongbin.top:3006/api/getbooks', function(res) {
                    var data = res.data;

                    data.sort((a, b) => {
                            return a.id - b.id
                        }) // 正序排列
                    console.log(data)
                    var str = ''
                    data.forEach(item => {

                        str += `
                         <div>id : ${item.id} | 书名 : ${item.bookname} | 作者 : ${item.author} | 出版社 : ${item.publisher} </div> 
                     `
                    });
                    $('.box').html(str)
                })
            })
        })
    </script>
</body>

</html>